﻿const monsterHealthBar = document.getElementById('monster-health');
const playerHealthBar = document.getElementById('player-health');
const bonusLifeEl = document.getElementById('bonus-life');

const attackBtn = document.getElementById('attack-btn');
const strongAttackBtn = document.getElementById('strong-attack-btn');
const healBtn =  document.getElementById('heal-btn');
const logBtn = document.getElementById('log-btn');

function adjustHealthBars(maxLife){
    monsterHealthBar.max = maxLife;
    monsterHealthBar.value = maxLife;
    playerHealthBar.max = maxLife;
    playerHealthBar.value = maxLife;
}

function dealMonsterDamage(damage){
    const dealtDamage = Math.random() * damage;
    monsterHealthBar.value = +monsterHealthBar.value - dealtDamage;
    return dealtDamage;
}

function dealPlayerDamage(damage){
    const dealtDamage = Math.random() * damage;
    playerHealthBar.value = +monsterHealthBar.value - dealtDamage;
    return dealtDamage;
}

function increasePlayerHealth(healthValue){
    playerHealthBar.value = +playerHealthBar.value + healthValue;
}

function resetGame(){
    playerHealthBar.value = 100;
    monsterHealthBar.value = 100;
}

function removeBonusLife(){
    bonusLifeEl.parentNode.removeChild(bonusLifeEl);
}

function setPlayerHealth(healthValue){
    playerHealthBar.value = healthValue;
}
